package com.lzh.seatrend.config.datasource.mysqlDataSource;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tk.mybatis.spring.mapper.MapperScannerConfigurer;

import java.util.Properties;

/**
 * @Classname SecondDataSourceMapperScannerConfig
 * @Description SecondDataSourceMapperScannerConfig
 * @Date 2021/11/29 14:30
 * @Created by liuzihao
 */
@Configuration
@AutoConfigureAfter(SecondDataSourceConfig.class)
public class SecondDataSourceMapperScannerConfig {

    private static final String SqlSessionFactory = "sqlSessionFactorySecond";
    private static final String BasePackage = "com.lzh.springsecurity.secondmapper";

    @Bean
    public MapperScannerConfigurer mapperScannerConfigurerSecond(){
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        mapperScannerConfigurer.setSqlSessionFactoryBeanName(SqlSessionFactory);
        mapperScannerConfigurer.setBasePackage(BasePackage);
        Properties properties = new Properties();
        properties.setProperty("mappers","com.lzh.springsecurity.common.dao.BaseMapper");
        properties.setProperty("notEmpty","false");
        properties.setProperty("IDENTITY","MYSQL");
        mapperScannerConfigurer.setProperties(properties);
        return mapperScannerConfigurer;
    }
}
